import axios from "../utils/axiosUtils";
import {IUser2} from "@/interfaces/userInterface"
import {IMyuser,IMyuser2} from "@/interfaces/userInterface"
import objectToFormString from "@/utils/ObjectReverseForm";

/**
 * 登录接口
 * @param data 
 * @returns 
 */
export const loginApi = (data:IUser2)=>{
    const loginStr = "username=bobo&password=1234qwer"
    return axios.post("/login",loginStr)
}

/**
 * 查询用户
 * @param data 
 * @returns 
 */
export const findAllUserApi = (data:IMyuser)=>{
    return axios.get("/user",{
        params:data
    })
}

export const addUserApi = (data:IMyuser2)=>{
    //将接受到对象转化为字符串来进行传递
    const res = objectToFormString(data)
    return axios.post("/user",res)
}